use std::cmp::Ordering;

pub struct Solution;

impl Solution {
    pub fn final_string(s: String) -> String {
        let mut result = String::new();
        s.chars().for_each(|c| {
            match c.cmp(&'i') {
                Ordering::Equal => {
                    result = result.chars().rev().collect();
                }
                _ => result.push(c),
            }
        });
        result
    }
}